package com.conph.moring.core;

import java.lang.reflect.Method;

/**
 * 拦截目标类
 * 其中包含被拦截目标方法对象及其所在的类对象。
 * @author Lconf
 *
 */
public class IntercepterTargetDefination {
	private Class<?> targetClass;
	private Method targetMethod;
	
	public IntercepterTargetDefination(Class<?> targetClass, Method targetMethod) {
		this.targetClass = targetClass;
		this.targetMethod = targetMethod;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((targetClass == null) ? 0 : targetClass.hashCode());
		result = prime * result + ((targetMethod == null) ? 0 : targetMethod.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		IntercepterTargetDefination other = (IntercepterTargetDefination) obj;
		if (targetClass == null) {
			if (other.targetClass != null)
				return false;
		} else if (!targetClass.equals(other.targetClass))
			return false;
		if (targetMethod == null) {
			if (other.targetMethod != null)
				return false;
		} else if (!targetMethod.equals(other.targetMethod))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "IntercepterTargetDefination{" +
				"targetClass=" + targetClass +
				", targetMethod=" + targetMethod +
				'}';
	}

	protected Class<?> getTargetClass() {
		return targetClass;
	}
	
	protected void setTargetClass(Class<?> targetClass) {
		this.targetClass = targetClass;
	}
	
	protected Method getTargetMethod() {
		return targetMethod;
	}
	
	protected void setTargetMethod(Method targetMethod) {
		this.targetMethod = targetMethod;
	}
	
}
